import maya.cmds as mc

import LZ_public_command.LZ_UI
reload(LZ_public_command.LZ_UI)

import LZ_public_command.LZ_Attribute
reload(LZ_public_command.LZ_Attribute)

import LZ_public_command.LZ_sdk_command
reload(LZ_public_command.LZ_sdk_command)

class SDK_Tools(LZ_public_command.LZ_UI.LZ_UI,
                LZ_public_command.LZ_sdk_command.LZ_sdk_command,
                LZ_public_command.LZ_Attribute.LZ_attribute
                
                ):
    def __init__(self):
        pass
        
    def SDK_UI(self):
        mdlar_SDK_UI = 'mdlar_SDK_UI'
        if mc.window(mdlar_SDK_UI,ex = True):
            mc.deleteUI(mdlar_SDK_UI)
            
        mc.window(mdlar_SDK_UI,widthHeight=(450, 400),t=mdlar_SDK_UI,menuBar = True,rtf=True,s=True)

        main = mc.columnLayout('mdlar_SDK_main',columnAttach=('both', 5), rowSpacing=10, columnWidth=450 )
        
        ###===========================================================================================================
        #-----------------------------------   eyeBrow  sdk setting    ---------------------------------------------
        
        mc.frameLayout( 'eyeBrow_SDK_frameLY',label='eyeBrow_SDK_mdlar', borderStyle='in',collapsable=False,bgc =(0.1,0.1,0.1) ,font = 'boldLabelFont')
        
        mc.text('please select the  "ac_lf_eyebrow_ctrl" and load to textField lower ')
        
        ##
        mc.rowLayout( 'loadEyeBrow_rowLY',numberOfColumns=3,columnWidth3=(100, 250,100), adjustableColumn=3, columnAlign=(1, 'right'), columnAttach=[(1, 'both', 0), (2, 'both', 0), (2, 'both', 0)])
        mc.text(  ' eyeBrow_prefix :  ')
        mc.textField( 'loadEyeBrow_SDK_textField',text='' )
        mc.button('load_eyeBrow' ,c = lambda *args:self.load_SDK_prefix(  mdlar = 'eyeBrow') )
        
        ##
        
        
        mc.setParent('eyeBrow_SDK_frameLY')
        mc.radioButtonGrp( 'eyeBrow_SDK_mdlar',label='eyeBrow_mdlar       ', labelArray3=['left', 'right', 'both'], numberOfRadioButtons=3,sl=3 )
        
        mc.rowLayout( 'eyeBrow_SDK_rowLY',numberOfColumns=3,columnWidth3=(100, 30,200), adjustableColumn=3, columnAlign=(1, 'right'), columnAttach=[(1, 'both', 0), (2, 'both', 0), (2, 'both', 0)])

        mc.textScrollList('eyeBrow_SDK_DriverList',allowMultiSelection=False, height =  100,width = 100,sc=lambda *args:self.EyeBrow_sdk_DRclickCommand())
        mc.columnLayout('eyeBrow_text_list',columnWidth=500)
        
        mc.setParent('eyeBrow_SDK_rowLY')
        mc.textScrollList('eyeBrow_SDK_DrivenList',allowMultiSelection=False, height =  100,width = 300,sc=lambda *args:self.EyeBrow_sdk_DVclickCommand())
        
        mc.setParent('eyeBrow_SDK_frameLY')
        
        mc.rowLayout( 'eyeBrow_SDK_button_rowLY',numberOfColumns=2,columnWidth2=(220,220), adjustableColumn=2, columnAlign=(1, 'right'), columnAttach=[(1, 'both', 0), (2, 'both', 0)])
        
        mc.button('modify' ,c = lambda *args:self.EyeBrow_sdk_Modify(  ) )
        
        mc.button('cancle' ,c = lambda *args:self.eyeBrown_sdk_cancle( ) )
        
        mc.setParent('eyeBrow_SDK_frameLY')
        
        mc.rowLayout( 'eyeBrow_CorrectBlendshape_button_rowLY',numberOfColumns=3,columnWidth3=(140,140,140), adjustableColumn=3, columnAlign=(1, 'right'), columnAttach=[(1, 'both', 0), (2, 'both', 0)])
        
        mc.button('correctCurrectShape' ,c = lambda *args:self.EyeBrow_sdk_Modify(  ) )
        mc.button('finish_correct' ,c = lambda *args:self.EyeBrow_sdk_Modify(  ) )
        
        mc.button('cancle' ,c = lambda *args:self.eyeBrown_sdk_cancle( ) )
        
        ###===========================================================================================================
        #-----------------------------------   eyelid  sdk setting    ---------------------------------------------
        mc.setParent('eyeBrow_SDK_frameLY')
        mc.frameLayout( 'eyelid_SDK_frameLY',label='eyeBrow_SDK_mdlar', borderStyle='in',collapsable=False,bgc =(0.1,0.1,0.1) ,font = 'boldLabelFont')
        
        mc.text('please select the  "ac_lf_eyebrow_ctrl" and load to textField lower ')
        
        ##
        mc.rowLayout( 'loadEyelid_rowLY',numberOfColumns=3,columnWidth3=(100, 250,100), adjustableColumn=3, columnAlign=(1, 'right'), columnAttach=[(1, 'both', 0), (2, 'both', 0), (2, 'both', 0)])
        mc.text(  ' eyelid_prefix :  ')
        mc.textField( 'loadEyelid_SDK_textField',text='' )
        mc.button('load_eyelid' ,c = lambda *args:self.load_SDK_prefix(  mdlar = 'eyeBrow') )
        
        ##
        
        
        mc.setParent('eyelid_SDK_frameLY')
        mc.radioButtonGrp( 'eyelid_SDK_mdlar',label='eyeBrow_mdlar       ', labelArray3=['left', 'right', 'both'], numberOfRadioButtons=3,sl=3 )
        
        mc.rowLayout( 'eyelid_SDK_rowLY',numberOfColumns=3,columnWidth3=(100, 30,200), adjustableColumn=3, columnAlign=(1, 'right'), columnAttach=[(1, 'both', 0), (2, 'both', 0), (2, 'both', 0)])

        mc.textScrollList('eyelid_SDK_DriverList',allowMultiSelection=False, height =  100,width = 100,sc=lambda *args:self.eyelid_sdk_DRclickCommand())
        mc.columnLayout('eyelid_text_list',columnWidth=500)
        
        mc.setParent('eyelid_SDK_rowLY')
        mc.textScrollList('eyelid_SDK_DrivenList',allowMultiSelection=False, height =  100,width = 300,sc=lambda *args:self.Eyelid_sdk_DVclickCommand())
        
        mc.setParent('eyelid_SDK_frameLY')
        
        mc.rowLayout( 'eye_SDK_button_rowLY',numberOfColumns=2,columnWidth2=(220,220), adjustableColumn=2, columnAlign=(1, 'right'), columnAttach=[(1, 'both', 0), (2, 'both', 0)])
        mc.button('modify_eyelid' ,l='modify',c = lambda *args:self.Eyelid_sdk_Modify(  ) )
        
        mc.button('cancle_eyelid' ,l='cancle',c = lambda *args:self.eyelid_sdk_cancle( ) )
        
        mc.setParent('eyeBrow_SDK_frameLY')
        
        mc.rowLayout( 'eye_CorrectBlendshape_button_rowLY',numberOfColumns=3,columnWidth3=(140,140,140), adjustableColumn=3, columnAlign=(1, 'right'), columnAttach=[(1, 'both', 0), (2, 'both', 0)])
        
        mc.button('eye_correctCurrectShape' , l = 'eye_correctCurrectShape',c = lambda *args:self.EyeBrow_sdk_Modify(  ) )
        mc.button('eye_finish_correct' , l = 'eye_finish_correct',c = lambda *args:self.EyeBrow_sdk_Modify(  ) )
        
        mc.button('eye_correct_cancle' , l = 'eye_correct_cancle', c = lambda *args:self.eyeBrown_sdk_cancle( ) )
        
        ###===========================================================================================================
        #-----------------------------------   mouth sdk setting    ---------------------------------------------
        
        mc.setParent( 'eyeBrow_SDK_frameLY')
        mc.frameLayout( 'mouth_SDK_frameLY',label='mouth_SDK_mdlar', borderStyle='in',collapsable=False,bgc =(0.1,0.1,0.1) ,font = 'boldLabelFont')
        mc.text('please select the  "ac_rt_mouth_ctrl" and load to textField lower ')
        
        ##
        mc.rowLayout( 'loadmouth_sdk_rowLY',numberOfColumns=3,columnWidth3=(100, 250,100), adjustableColumn=3, columnAlign=(1, 'right'), columnAttach=[(1, 'both', 0), (2, 'both', 0), (2, 'both', 0)])
        mc.text(  ' mouth_prefix :  ')
        mc.textField( 'loadMouth_SDK_textField',text='' )
        mc.button('load_mouth' ,c = lambda *args:self.load_SDK_prefix(  mdlar = 'mouth') )
        
        ##
        
        
        mc.setParent('mouth_SDK_frameLY')
        mc.radioButtonGrp( 'mouth_SDK_mdlar',label='mouth_side:      ', labelArray3=['left', 'right', 'both'], numberOfRadioButtons=3,sl=3 )
        
        mc.rowLayout( 'mouth_SDK_rowLY',numberOfColumns=3,columnWidth3=(100, 30,300), adjustableColumn=3, columnAlign=(1, 'right'), columnAttach=[(1, 'both', 0), (2, 'both', 0), (2, 'both', 0)])

        mc.textScrollList('mouth_SDK_DriverList',allowMultiSelection=False, height =  75,width = 100,sc=lambda *args:self.mouth_sdk_DRclickCommand())
        mc.columnLayout('mouth_text_list',columnWidth=500)
        
        mc.setParent('mouth_SDK_rowLY')
        mc.textScrollList('mouth_SDK_DrivenList',allowMultiSelection=False, height =  75,width = 300,sc=lambda *args:self.mouth_sdk_DVclickCommand())
        
        mc.setParent('mouth_SDK_frameLY')
        
        mc.rowLayout( 'eye_SDK_button_rowLY',numberOfColumns=2,columnWidth2=(220,220), adjustableColumn=2, columnAlign=(1, 'right'), columnAttach=[(1, 'both', 0), (2, 'both', 0)])
        mc.button('mouth_modify' ,l='modify',c = lambda *args:self.mouth_sdk_Modify(  ) )
        
        
        ##================================================================================================================================
        #--------------  -------------------------------------------------
        for eyeBrowEmotion in [ 'up' , 'dn' ,'inn','out','front']:
            mc.textScrollList('eyeBrow_SDK_DriverList', e=True,append=eyeBrowEmotion)
            
        for mouthEmotion in [ 'open','lf_zipper'  ]:
            mc.textScrollList('mouth_SDK_DriverList', e=True,append=mouthEmotion)
        
        for eyelidEmotion in [ 'close','close_upper' ,'close_lower','open' ]:
            mc.textScrollList('eyelid_SDK_DriverList', e=True,append=eyelidEmotion)
        
        mc.showWindow(mdlar_SDK_UI)
    def load_SDK_prefix(self , mdlar = 'eyeBrow'):
        objsel = mc.ls(sl=True)
        
        eyeBrowCtrlOrg = 'ac_lf_eyebrow_ctrl'
        eyeBrowTextField = 'loadEyeBrow_SDK_textField'
        
        mouthCtrlOrg = 'ac_cn_lip_ctrl'
        mouthTextField = 'loadMouth_SDK_textField'
        
        if mdlar == 'eyeBrow':
            orgText = eyeBrowCtrlOrg
            textField_input = eyeBrowTextField
        elif mdlar=='mouth':
            orgText = mouthCtrlOrg
            textField_input = mouthTextField
        else:
            orgText = ''
            textField_input = ''
            
        if orgText in objsel[0]:
            pre = str(objsel[0]).split(orgText)[0]
        
            mc.textField(  textField_input ,e=True,text=pre )
            
        print( [orgText,objsel])
    ####==============================================================================================
    #-----------------------------  eyeBrow  sdk ---------------------------------------------------------  
    
    def EyeBrow_sdk_DRclickCommand(self):
        prefix =  mc.textField( 'loadEyeBrow_SDK_textField',q=True,text=True )
        currentEmotion = mc.textScrollList('eyeBrow_SDK_DriverList',q=True, selectItem =True )
        mdlar = mc.radioButtonGrp( 'eyeBrow_SDK_mdlar', q=True, sl=True )
        offset_eyeBrow = ['ac_lf_eyebrow1_influenceCL_offset','ac_lf_eyebrow2_influenceCL_offset','ac_lf_eyebrow3_influenceCL_offset','ac_lf_eyebrow4_influenceCL_offset','ac_lf_eyebrow5_influenceCL_offset']
        limit_info =  [ ('up',(1,1,0,0),(1,1,1,1),(1,1,0,0)),('dn',(1,1,0,0),(-1,-1,1,1),(1,1,0,0)),('inn',(-1,-1,1,1),(1,1,0,0),(1,1,0,0)),('out',(1,1,1,1),(1,1,0,0),(1,1,0,0)),('front',(1,1,0,0),(1,1,0,0),(1,1,1,1))]
        driven_obj = []
        
        mc.textScrollList('eyeBrow_SDK_DrivenList', e=True,ra=True )
        for oe in offset_eyeBrow:
            if mdlar==2:
                rt_obj = str(oe).replace('lf_','rt_')
                driven_obj.append( prefix + rt_obj)
            else:
                driven_obj.append( prefix + oe)
                
        for do in driven_obj:
            mc.textScrollList( 'eyeBrow_SDK_DrivenList', e=True,append = do )
        

        ctrl = prefix + 'ac_lf_eyebrow_ctrl'
        #print(ctrl)
        if mdlar==2:
            driver = str(ctrl).replace('lf_','rt_' )
        else:
            driver = ctrl 
        
        mc.transformLimits( driver , etx=(0,0), ety = (0,0) , etz = (0,0) )
        mc.setAttr( str(driver) + '.tx',0 )
        mc.setAttr( str(driver) + '.ty',0 )
        mc.setAttr( str(driver) + '.tz',0 )
        
        
        
        for li in  limit_info: 
            #print( ( li[0] , currentEmotion  ))

            if currentEmotion[0] == li[0]:
                #print(1)
                mc.transformLimits( driver ,tx = ( li[1][0] , li[1][1] ) , etx =( li[1][2] , li[1][3]) ,ty=( li[2][0] , li[2][1] ) , ety = (li[2][2] , li[2][3])  ,tz=( li[3][0] , li[3][1] )  , etz = ( li[3][2] , li[3][3] ) )
                break
            else:
                mc.transformLimits( driver , etx=(0,0), ety = (0,0) , etz = (0,0) )
                
        
    def EyeBrow_sdk_DVclickCommand(self):
        currentEmotion = mc.textScrollList('eyeBrow_SDK_DrivenList',q=True, selectItem =True )
        
            
        mc.select(currentEmotion[0])
        
    def EyeBrow_sdk_Modify(self):
        prefix =  mc.textField( 'loadEyeBrow_SDK_textField',q=True,text=True )
        
        bridgeGrp = prefix + 'eyeBrow_bridge'
        ctrl = prefix + 'ac_lf_eyebrow_ctrl'
        rt_ctrl = prefix + 'ac_rt_eyebrow_ctrl'
        
        offset_eyeBrow = ['ac_lf_eyebrow1_influenceCL_offset','ac_lf_eyebrow2_influenceCL_offset','ac_lf_eyebrow3_influenceCL_offset','ac_lf_eyebrow4_influenceCL_offset','ac_lf_eyebrow5_influenceCL_offset']
        
        currentEmotion = mc.textScrollList('eyeBrow_SDK_DriverList',q=True, selectItem =True )
        
        ifnfo_SDK = [ ('up','lf_brow_offset_up'),('dn','lf_brow_offset_dn'),('inn','lf_brow_offset_inn'),('out','lf_brow_offset_out'),('front','lf_brow_offset_fn')]
        mdlar = mc.radioButtonGrp( 'eyeBrow_SDK_mdlar', q=True,sl=True )
        for info in ifnfo_SDK:
            if currentEmotion[0] == info[0]:
                #mc.setAttr( str(ctrl)+',translateY' , 1  )
                
                if currentEmotion[0] == 'up':
                    if mdlar== 1  :
                        self.eyeBrown_sdk_singgle(  mirrorSetting = 'left'  , eyeBrown_dir = 'up' )
                    if mdlar== 2  :
                        self.eyeBrown_sdk_singgle(  mirrorSetting = 'right'  , eyeBrown_dir = 'up' )
                    if mdlar== 3  :
                        self.eyeBrown_sdk_singgle(  mirrorSetting = 'left'  , eyeBrown_dir = 'up' )
                        self.eyeBrown_sdk_singgle(  mirrorSetting = 'right'  , eyeBrown_dir = 'up' )
                        
                if currentEmotion[0] == 'dn':
                    if mdlar== 1  :
                        self.eyeBrown_sdk_singgle(  mirrorSetting = 'left'  , eyeBrown_dir = 'dn' )
                    if mdlar== 2  :
                        self.eyeBrown_sdk_singgle(  mirrorSetting = 'right'  , eyeBrown_dir = 'dn' )
                    if mdlar== 3  :
                        self.eyeBrown_sdk_singgle(  mirrorSetting = 'left'  , eyeBrown_dir = 'dn' )
                        self.eyeBrown_sdk_singgle(  mirrorSetting = 'right'  , eyeBrown_dir = 'dn' )
                
                for oe in offset_eyeBrow:
                    
                    
                    lf_attr = info[1]
                    rt_attr = str(info[1]).replace('lf_','rt_')
                    if mdlar== 1:
                        drivenObj = prefix + oe
                    elif mdlar== 2:
                        drivenObj = prefix + str(oe).replace('lf_','rt_')
                        
                    elif mdlar== 3:
                        drivenObj =  prefix + oe 
                        
                        drivenObj_rt = prefix + str(oe).replace('lf_','rt_')
                    
                    
                    for attr in ['tx' ,'ty' ,'tz' ]:
                        value = mc.getAttr( str(drivenObj)+'.'+ attr )
                        if mdlar== 1:
                            
                            self.LZ_setDrivenKey( driverAttr = str(bridgeGrp)+'.' + lf_attr ,drivenAttr = str(drivenObj)+'.'+ attr , driverV=1,drivenV = value )
                        
                        if mdlar== 2:
                            
                            self.LZ_setDrivenKey( driverAttr = str(bridgeGrp)+'.' + rt_attr ,drivenAttr = str(drivenObj)+'.'+ attr , driverV=1,drivenV = value )
                        
                        if mdlar== 3:
                            
                            if attr == 'tx':
                                rtAt = value*-1
                            else:
                                rtAt = value
                            #bridgeAttr = str( lf_attr ).replace('lf_','rt_')
                            
                            self.LZ_setDrivenKey( driverAttr = str(bridgeGrp)+'.' + lf_attr ,drivenAttr = str(drivenObj)+'.'+ attr , driverV=1,drivenV = value )
                            
                            self.LZ_setDrivenKey( driverAttr = str(bridgeGrp)+'.' + rt_attr ,drivenAttr = str(drivenObj_rt)+'.'+ attr , driverV=0,drivenV = 0 )
                            self.LZ_setDrivenKey( driverAttr = str(bridgeGrp)+'.' + rt_attr ,drivenAttr = str(drivenObj_rt)+'.'+ attr , driverV=1,drivenV = rtAt )
                
                if currentEmotion[0] == 'up':
                    if mdlar== 1  :
                        self.eyeBrown_sdk_singgle(  mirrorSetting = 'left'  , eyeBrown_dir = 'up' )
                    if mdlar== 2  :
                        
                        mc.setAttr( str(rt_ctrl)+'.translateY' , 1 )
                        self.eyeBrown_sdk_singgle(  mirrorSetting = 'right'  , eyeBrown_dir = 'up' )
                        mc.setAttr( str(rt_ctrl)+'.translateY' , 0 )
                        
                    if mdlar== 3  :
                        mc.setAttr( str(rt_ctrl)+'.translateY' , 1 )
                        self.eyeBrown_sdk_singgle(  mirrorSetting = 'left'  , eyeBrown_dir = 'up' )
                        self.eyeBrown_sdk_singgle(  mirrorSetting = 'right'  , eyeBrown_dir = 'up' )
                        mc.setAttr( str(rt_ctrl)+'.translateY' , 0 )
                        
                if currentEmotion[0] == 'dn':
                    if mdlar== 1  :
                        self.eyeBrown_sdk_singgle(  mirrorSetting = 'left'  , eyeBrown_dir = 'dn' )
                    if mdlar== 2  :
                        mc.setAttr( str(rt_ctrl)+'.translateY' , -1 )
                        self.eyeBrown_sdk_singgle(  mirrorSetting = 'right'  , eyeBrown_dir = 'dn' )
                        mc.setAttr( str(rt_ctrl)+'.translateY' , 0 )
                        
                    if mdlar== 3  :
                        mc.setAttr( str(rt_ctrl)+'.translateY' , -1 )
                    
                        self.eyeBrown_sdk_singgle(  mirrorSetting = 'left'  , eyeBrown_dir = 'dn' )
                        self.eyeBrown_sdk_singgle(  mirrorSetting = 'right'  , eyeBrown_dir = 'dn' )
                        
                        mc.setAttr( str(rt_ctrl)+'.translateY' , 0 )
                        
                        
                mc.transformLimits( ctrl , etx=(0,0), ety = (0,0) , etz = (0,0))
                mc.transformLimits( rt_ctrl , etx=(0,0), ety = (0,0) , etz = (0,0))
                mc.setAttr( str(ctrl)+'.translateY' , 0 )
                mc.setAttr( str(ctrl)+'.translateX' , 0 )
                
                
                
                    
    def eyeBrown_sdk_cancle(self):
        prefix =  mc.textField( 'loadEyeBrow_SDK_textField',q=True,text=True )
        
        
        bridgeGrp = prefix + 'eyeBrow_bridge'
        ctrl = prefix + 'ac_lf_eyebrow_ctrl'
        rt_ctrl = prefix + 'ac_rt_eyebrow_ctrl'
        
        mc.transformLimits( ctrl , etx=(0,0), ety = (0,0) , etz = (0,0))
        mc.transformLimits( rt_ctrl , etx=(0,0), ety = (0,0) , etz = (0,0))
        
        mc.setAttr( str(ctrl)+'.translateY' , 0 )
        mc.setAttr( str(ctrl)+'.translateX' , 0 )
        
        mc.setAttr( str(rt_ctrl)+'.translateY' , 0 )
        mc.setAttr( str(rt_ctrl)+'.translateX' , 0 )
        
        
        
    def eyeBrown_sdk_singgle(self, mirrorSetting = 'left' ,eyeBrown_dir = 'up'):   # mirrorSetting = 'left' or 'right'    eyeBrown_dir =   'up'  or  'dn'
        prefix =  mc.textField( 'loadEyeBrow_SDK_textField',q=True,text=True )
        
        bridgeGrp = prefix + 'eyeBrow_bridge'
        left_ctrl = prefix + 'ac_lf_eyebrow_ctrl'
        right_ctrl = prefix + 'ac_rt_eyebrow_ctrl'
        
        left_locators = ['ac_lf_eyebrow1_sdk_driver','ac_lf_eyebrow2_sdk_driver','ac_lf_eyebrow3_sdk_driver','ac_lf_eyebrow4_sdk_driver','ac_lf_eyebrow5_sdk_driver']
        right_locators = ['ac_rt_eyebrow1_sdk_driver','ac_rt_eyebrow2_sdk_driver','ac_rt_eyebrow3_sdk_driver','ac_rt_eyebrow4_sdk_driver','ac_rt_eyebrow5_sdk_driver']
        
        eyeBrown_locs = []
        
        
        if mirrorSetting == 'left':
            ctrl = left_ctrl
            locators = left_locators
        else:
            ctrl = right_ctrl
            locators = right_locators
        
        for loc in locators:
            locator_eyeBrown = prefix + loc
            
            eyeBrown_locs.append(locator_eyeBrown)
            transY_attr = str(locator_eyeBrown)+'.translateY'
            
            loc_translateY = mc.getAttr(transY_attr)
            #print([transY_attr,loc_translateY])
            
            sdk_info = self.getSDKconnectionInfo( transY_attr, bridgeGrp )
            print([ transY_attr ,loc_translateY])
            
            
            if eyeBrown_dir == 'up':
                for info in sdk_info :
                    if 'up' in  info[2]:
                        #print(info[2])
                        mount = self.query_mount_keyframe( aini_node = info[1]  )
                        #print(mount)
                        if mount == 1:
                            #print(info[2])
                            self.LZ_setDrivenKey( transY_attr,info[2],999,0 )
                        
                        if loc_translateY > 0 :
                            first = 0
                            secondry = loc_translateY
                            
                            first_v = 0
                            secondry_v = 1
                        else:
                            first = loc_translateY
                            secondry = 0
                            
                            first_v = 1
                            secondry_v = 0
                        
                        self.modify_ani_node_float(  aini_node = info[1] ,float = ( 0,0) ,floatValue = first )
                        self.modify_ani_node_float(  aini_node = info[1] ,float = ( 1,1) ,floatValue = secondry )
                        
                        self.modify_ani_node_value(  aini_node = info[1] ,float = ( 0,0) ,Value = first_v)
                        self.modify_ani_node_value(  aini_node = info[1] ,float = ( 1,1) ,Value = secondry_v)
            else:
                for info in sdk_info :
                    if 'dn' in  info[2]:
                        #print(info[2])
                        
                        
                        
                        mount = self.query_mount_keyframe( aini_node = info[1]  )
                        if mount == 1:
                            self.LZ_setDrivenKey( transY_attr,info[2],999,0 )
                        if loc_translateY > 0 :
                            first = 0
                            secondry = loc_translateY
                            
                            first_v = 0
                            secondry_v = 1
                        else:
                            first = loc_translateY
                            secondry = 0
                            
                            first_v = 1
                            secondry_v = 0
                            
                            
                        self.modify_ani_node_float(  aini_node = info[1] ,float = ( 0,0) ,floatValue = first )
                        self.modify_ani_node_float(  aini_node = info[1] ,float = ( 1,1) ,floatValue = secondry )
                        
                        self.modify_ani_node_value(  aini_node = info[1] ,float = ( 0,0) ,Value = first_v)
                        self.modify_ani_node_value(  aini_node = info[1] ,float = ( 1,1) ,Value = secondry_v)
    

    ####==============================================================================================
    #-----------------------------  eyeBrow  sdk ---------------------------------------------------------      
    
    def eyelid_sdk_DRclickCommand(self):
    
        prefix =  mc.textField( 'loadMouth_SDK_textField',q=True,text=True )
        currentEmotion = mc.textScrollList('eyelid_SDK_DriverList',q=True, selectItem =True )[0]
        lf_ctrl_upper =  prefix + 'ac_lf_upperlid_ctrl'
        rt_ctrl_upper =  prefix + 'ac_rt_upperlid_ctrl'
        
        lf_ctrl_lower =  prefix + 'ac_lf_lowerlid_ctrl'
        rt_ctrl_lower =  prefix + 'ac_rt_lowerlid_ctrl'
        
        lf_uplid = prefix + 'ac_lf_upperlid_jnt_offset'
        lf_lowlid = prefix + 'ac_lf_lowerlid_jnt_offset'
        
        rt_uplid = prefix + 'ac_rt_upperlid_jnt_offset'
        rt_lowlid = prefix + 'ac_rt_lowerlid_jnt_offset'
        
        
        lf_bridge =  prefix + 'ac_lf_eyecrunch_bridge'
        rt_bridge =  prefix + 'ac_rt_eyecrunch_bridge'
    
        mc.textScrollList('eyelid_SDK_DrivenList', e=True,ra=True )
        
        mdlar = mc.radioButtonGrp( 'eyelid_SDK_mdlar', q=True, sl=True )
        
        lf_lid = [lf_uplid,lf_lowlid]
        rt_lid = [rt_uplid,rt_lowlid]
        
        #print(currentEmotion)
        if currentEmotion == 'close' or currentEmotion == 'close_upper'  or currentEmotion == 'close_lower' or currentEmotion == 'open':
            
        
        
            for i in range(2):
                if mdlar == 1:
                    ctrl_upper = lf_ctrl_upper
                    ctrl_lower = lf_ctrl_lower
                    mc.textScrollList( 'eyelid_SDK_DrivenList', e = True,append = lf_lid[i] )
                
                if mdlar == 2:
                
                    ctrl_upper = rt_ctrl_upper
                    ctrl_lower = rt_ctrl_lower
                    mc.textScrollList( 'eyelid_SDK_DrivenList', e = True,append = rt_lid[i] )
                
                if mdlar == 3:
                    ctrl_upper = lf_ctrl_upper
                    ctrl_lower = lf_ctrl_lower
                    mc.textScrollList( 'eyelid_SDK_DrivenList', e = True,append = lf_lid[i] )
            if currentEmotion == 'close':
                mc.setAttr(str(ctrl_upper)+'.translateY',-1)
                mc.setAttr(str(ctrl_lower)+'.translateY',1)
               
            if currentEmotion == 'close_upper':
                mc.setAttr(str(ctrl_upper)+'.translateY',-2)
                mc.setAttr(str(ctrl_lower)+'.translateY',0)
            
            if currentEmotion == 'close_lower':
                mc.setAttr(str(ctrl_upper)+'.translateY',0)
                mc.setAttr(str(ctrl_lower)+'.translateY',2)
               
            if currentEmotion == 'open':
                mc.setAttr(str(ctrl_upper)+'.translateY',1)
                mc.setAttr(str(ctrl_lower)+'.translateY',-1)
                
    def Eyelid_sdk_DVclickCommand(self):
        currentEmotion = mc.textScrollList('eyelid_SDK_DrivenList',q=True, selectItem =True )
        
            
        mc.select(currentEmotion[0])
        
    def eyelid_sdk_cancle(self):
        prefix =  mc.textField( 'loadMouth_SDK_textField',q=True,text=True )
        
        lf_ctrl_upper =  prefix + 'ac_lf_upperlid_ctrl'
        rt_ctrl_upper =  prefix + 'ac_rt_upperlid_ctrl'
        
        lf_ctrl_lower =  prefix + 'ac_lf_lowerlid_ctrl'
        rt_ctrl_lower =  prefix + 'ac_rt_lowerlid_ctrl'
        
        
        for i in [lf_ctrl_upper,rt_ctrl_upper,lf_ctrl_lower,rt_ctrl_lower]:
            mc.setAttr(str(i)+'.translateY' , 0 )
        
    def Eyelid_sdk_Modify(self):
        prefix =  mc.textField( 'loadMouth_SDK_textField',q=True,text=True )
        mdlar = mc.radioButtonGrp( 'eyelid_SDK_mdlar', q=True, sl=True )
        currentEmotion = mc.textScrollList('eyelid_SDK_DriverList',q=True, selectItem =True )[0]
        
        lf_uplid = prefix + 'ac_lf_upperlid_jnt_offset'
        lf_lowlid = prefix + 'ac_lf_lowerlid_jnt_offset'
        
        rt_uplid = prefix + 'ac_rt_upperlid_jnt_offset'
        rt_lowlid = prefix + 'ac_rt_lowerlid_jnt_offset'
        
        lf_bridge =  prefix + 'ac_lf_eyecrunch_bridge'
        rt_bridge =  prefix + 'ac_rt_eyecrunch_bridge'
        
        value_upper_lf = mc.getAttr( str(lf_uplid) + '.rotateZ')
        value_lower_lf = mc.getAttr( str(lf_lowlid) + '.rotateZ')
        value_upper_rt = mc.getAttr( str(rt_uplid) + '.rotateZ')
        value_lower_rt = mc.getAttr( str(rt_lowlid) + '.rotateZ')
        
        
        if currentEmotion == 'close':
            if mdlar == 1 or mdlar == 3 :
                ani_node_upper = self.findNode_animation( driver = str(lf_bridge) + '.upperlid_close' , driven = str(lf_uplid)+'.rotateZ' )
                ani_node_lower = self.findNode_animation( driver = str(lf_bridge) + '.lowerlid_close' , driven = str(lf_lowlid)+'.rotateZ' )
                
                #self.modify_ani_node_float(  aini_node = ani_node_upper ,float = ( 1,1) ,floatValue = 1)
                
                self.modify_ani_node_value(  aini_node = ani_node_upper ,float = ( 1,1) ,Value = value_upper_lf )
                self.modify_ani_node_value(  aini_node = ani_node_lower ,float = ( 1,1) ,Value = value_lower_lf )
                
                if mdlar == 3 :
                    
                    ani_node_upper_rt = self.findNode_animation( driver = str(rt_bridge) + '.upperlid_close' , driven = str(rt_uplid)+'.rotateZ' )
                    ani_node_lower_rt = self.findNode_animation( driver = str(rt_bridge) + '.lowerlid_close' , driven = str(rt_lowlid)+'.rotateZ' )
                    
                    self.modify_ani_node_value(  aini_node = ani_node_upper_rt ,float = ( 1,1) ,Value = value_upper_lf )
                    self.modify_ani_node_value(  aini_node = ani_node_lower_rt ,float = ( 1,1) ,Value = value_lower_lf )
                
            if mdlar == 2  :
            
                ani_node_upper = self.findNode_animation( driver = str(rt_bridge) + '.upperlid_close' , driven = str(rt_uplid)+'.rotateZ' )
                ani_node_lower = self.findNode_animation( driver = str(rt_bridge) + '.lowerlid_close' , driven = str(rt_lowlid)+'.rotateZ' )
                
                #self.modify_ani_node_float(  aini_node = ani_node_upper ,float = ( 1,1) ,floatValue = 1)
                
                self.modify_ani_node_value(  aini_node = ani_node_upper ,float = ( 1,1) ,Value = value_upper_rt )
                self.modify_ani_node_value(  aini_node = ani_node_lower ,float = ( 1,1) ,Value = value_lower_rt )
                
        
        elif currentEmotion == 'close_upper':
            
            if mdlar == 1 or mdlar == 3 :
                ani_node_upper = self.findNode_animation( driver = str(lf_bridge) + '.upperlid_close' , driven = str(lf_uplid)+'.rotateZ' )
                #ani_node_lower = self.findNode_animation( driver = str(lf_bridge) + '.lowerlid_close' , driven = str(lf_lowlid)+'.rotateZ' )
                
                #self.modify_ani_node_float(  aini_node = ani_node_upper ,float = ( 1,1) ,floatValue = 1)
                
                self.modify_ani_node_value(  aini_node = ani_node_upper ,float = ( 2,2) ,Value = value_upper_lf )
                #self.modify_ani_node_value(  aini_node = ani_node_lower ,float = ( 1,1) ,Value = value_lower_lf )
                
                if mdlar == 3 :
                    
                    ani_node_upper_rt = self.findNode_animation( driver = str(rt_bridge) + '.upperlid_close' , driven = str(rt_uplid)+'.rotateZ' )
                    #ani_node_lower_rt = self.findNode_animation( driver = str(lf_bridge) + '.lowerlid_close' , driven = str(lf_lowlid)+'.rotateZ' )
                    
                    self.modify_ani_node_value(  aini_node = ani_node_upper_rt ,float = ( 2,2) ,Value = value_upper_lf )
                    #self.modify_ani_node_value(  aini_node = ani_node_lower_rt ,float = ( 1,1) ,Value = value_lower_lf )
                
            if mdlar == 2  :
            
                ani_node_upper = self.findNode_animation( driver = str(rt_bridge) + '.upperlid_close' , driven = str(rt_uplid)+'.rotateZ' )
                #ani_node_lower = self.findNode_animation( driver = str(rt_bridge) + '.lowerlid_close' , driven = str(rt_lowlid)+'.rotateZ' )
                
                #self.modify_ani_node_float(  aini_node = ani_node_upper ,float = ( 1,1) ,floatValue = 1)
                
                self.modify_ani_node_value(  aini_node = ani_node_upper ,float = ( 2,2) ,Value = value_upper_rt )
                #self.modify_ani_node_value(  aini_node = ani_node_lower ,float = ( 1,1) ,Value = value_lower_rt )
        
        elif currentEmotion == 'close_lower':
        
            if mdlar == 1 or mdlar == 3 :
                #ani_node_upper = self.findNode_animation( driver = str(lf_bridge) + '.upperlid_close' , driven = str(lf_uplid)+'.rotateZ' )
                ani_node_lower = self.findNode_animation( driver = str(lf_bridge) + '.lowerlid_close' , driven = str(lf_lowlid)+'.rotateZ' )
                
                #self.modify_ani_node_float(  aini_node = ani_node_upper ,float = ( 1,1) ,floatValue = 1)
                
                #self.modify_ani_node_value(  aini_node = ani_node_upper ,float = ( 1,1) ,Value = value_upper_lf )
                self.modify_ani_node_value(  aini_node = ani_node_lower ,float = ( 2,2) ,Value = value_lower_lf )
                
                if mdlar == 3 :
                    
                    #ani_node_upper_rt = self.findNode_animation( driver = str(lf_bridge) + '.upperlid_close' , driven = str(lf_uplid)+'.rotateZ' )
                    ani_node_lower_rt = self.findNode_animation( driver = str(rt_bridge) + '.lowerlid_close' , driven = str(rt_lowlid)+'.rotateZ' )
                    
                    #self.modify_ani_node_value(  aini_node = ani_node_upper_rt ,float = ( 1,1) ,Value = value_upper_lf )
                    self.modify_ani_node_value(  aini_node = ani_node_lower_rt ,float = ( 2,2) ,Value = value_lower_lf )
                
            if mdlar == 2   :
            
                #ani_node_upper = self.findNode_animation( driver = str(rt_bridge) + '.upperlid_close' , driven = str(rt_uplid)+'.rotateZ' )
                ani_node_lower = self.findNode_animation( driver = str(rt_bridge) + '.lowerlid_close' , driven = str(rt_lowlid)+'.rotateZ' )
                
                #self.modify_ani_node_float(  aini_node = ani_node_upper ,float = ( 1,1) ,floatValue = 1)
                
                #self.modify_ani_node_value(  aini_node = ani_node_upper ,float = ( 1,1) ,Value = value_upper_rt )
                self.modify_ani_node_value(  aini_node = ani_node_lower ,float = ( 2,2) ,Value = value_lower_rt )
        
        elif currentEmotion == 'open':
        
            if mdlar == 1 or mdlar == 3 :
                ani_node_upper = self.findNode_animation( driver = str(lf_bridge) + '.upperlid_close' , driven = str(lf_uplid)+'.rotateZ' )
                ani_node_lower = self.findNode_animation( driver = str(lf_bridge) + '.lowerlid_close' , driven = str(lf_lowlid)+'.rotateZ' )
                
                #self.modify_ani_node_float(  aini_node = ani_node_upper ,float = ( 1,1) ,floatValue = 1)
                
                self.modify_ani_node_value(  aini_node = ani_node_upper ,float = ( 1,1) ,Value = value_upper_lf )
                self.modify_ani_node_value(  aini_node = ani_node_lower ,float = ( 1,1) ,Value = value_lower_lf )
                
                if mdlar == 3 :
                    
                    ani_node_upper_rt = self.findNode_animation( driver = str(rt_bridge) + '.upperlid_close' , driven = str(rt_uplid)+'.rotateZ' )
                    ani_node_lower_rt = self.findNode_animation( driver = str(rt_bridge) + '.lowerlid_close' , driven = str(rt_lowlid)+'.rotateZ' )
                    
                    self.modify_ani_node_value(  aini_node = ani_node_upper_rt ,float = ( 1,1) ,Value = value_upper_lf )
                    self.modify_ani_node_value(  aini_node = ani_node_lower_rt ,float = ( 1,1) ,Value = value_lower_lf )
                
            if mdlar == 2  :
            
                ani_node_upper = self.findNode_animation( driver = str(rt_bridge) + '.upperlid_open' , driven = str(rt_uplid)+'.rotateZ' )
                ani_node_lower = self.findNode_animation( driver = str(rt_bridge) + '.lowerlid_open' , driven = str(rt_lowlid)+'.rotateZ' )
                
                #self.modify_ani_node_float(  aini_node = ani_node_upper ,float = ( 1,1) ,floatValue = 1)
                
                self.modify_ani_node_value(  aini_node = ani_node_upper ,float = ( 1,1) ,Value = value_upper_rt )
                self.modify_ani_node_value(  aini_node = ani_node_lower ,float = ( 1,1) ,Value = value_lower_rt )
        
        
    
    
    
    
    ####==============================================================================================
    #-----------------------------  mouth  sdk ---------------------------------------------------------
    
    def mouth_sdk_DRclickCommand(self):
        prefix =  mc.textField( 'loadMouth_SDK_textField',q=True,text=True )
        mdlar_section = mc.radioButtonGrp( 'mouth_SDK_mdlar', q=True, sl=True )
        mouthBridge_offset = prefix+'ac_cn_jaw_offset'
        ctrl = prefix +'ac_cn_jaw_ctrl'
        zipper_attr = ['L_zipper' , 'R_zipper']
        
        All_attr = mc.listAttr( mouthBridge_offset , k=True)
        
        
        mc.textScrollList('mouth_SDK_DrivenList', e =True,ra= True)
        
        
        sdk_driverEmotion = mc.textScrollList('mouth_SDK_DriverList', q =True,selectItem= True)
        lf_list = []
        rt_list = []
        
        
        for attr in All_attr:
            if attr in zipper_attr:
                pass
            else:
                
                if 'rt_' not in attr :
                    lf_list.append(attr)
        
                if 'lf_' not in attr :
                    rt_list.append(attr)
        ##---
        if sdk_driverEmotion[0] == 'open' : 
        
            poserLoc = prefix + 'jaw_poser_loctor'
            
            if mc.attributeQuery( 'open_angle' , node = poserLoc , ex = True ) == False:
                mc.addAttr( poserLoc ,ln = 'open_angle' ,k=True ,dv = 20 )
            
            valueAngle = mc.getAttr( str(poserLoc)+'.open_angle' ) 
            
            self.resetAllAttrs( ctrl_obj = ctrl )
            mc.setAttr( str(ctrl)+'.rotateX' , valueAngle )
            
            
            if mdlar_section == 1 or mdlar_section == 3:
                
                attr_list = lf_list
                
            elif mdlar_section == 2:
                attr_list = rt_list
            
            
            
            for sdk_attr in attr_list:
            
                connected_obj = mc.listConnections( str(mouthBridge_offset) +'.' + sdk_attr , s=False , d=True )

                sdk_ed  = mc.listConnections( str(connected_obj[0]) +'.output'  , s=False , d = True )
            
                mc.textScrollList('mouth_SDK_DrivenList', e =True,append = sdk_ed[0])
        
        if sdk_driverEmotion[0] == 'lf_zipper' : 
            mc.textScrollList('mouth_SDK_DrivenList', e =True,append = mouthBridge_offset)
            
            mc.setAttr( str(ctrl)+'.lf_lip_zipper' , 10 )
            mc.setAttr( str(ctrl)+'.rt_lip_zipper' , 0 )
        
    def mouth_sdk_DVclickCommand(self):
        sdk_driven_node = mc.textScrollList('mouth_SDK_DrivenList',q=True, selectItem =True )
        
            
        mc.select(sdk_driven_node[0])
        
        
    def mouth_sdk_Modify(self):
        
        prefix =  mc.textField( 'loadMouth_SDK_textField',q=True,text=True )
        mdlar_section = mc.radioButtonGrp( 'mouth_SDK_mdlar', q=True, sl=True )
        mouthBridge_offset = prefix+'ac_cn_jaw_offset'
        
        mouthBridge = prefix+ 'mouth_bridge_grp'
        
        
        ctrl = prefix +'ac_cn_jaw_ctrl'
        poserLoc = prefix + 'jaw_poser_loctor'
        
        zipper_attr = ['L_zipper' , 'R_zipper']
        
        All_attr = mc.listAttr( mouthBridge_offset , k=True)
        
        
        #mc.textScrollList('mouth_SDK_DrivenList', e =True,ra= True)
        
        
        sdk_driverEmotion = mc.textScrollList('mouth_SDK_DriverList', q =True,selectItem= True)
        lf_list = []
        rt_list = []
        
        for attr in All_attr:
            if attr in zipper_attr:
                pass
            else:
                
                if 'rt_' not in attr :
                    lf_list.append(attr)
        
                if 'lf_' not in attr :
                    rt_list.append(attr)

        if sdk_driverEmotion[0] == 'open' : 
            #===============================================
            
            currentAngle = mc.getAttr( str(ctrl)+'.rotateX' )
            mc.setAttr( str(poserLoc) + '.open_angle' , currentAngle )
            valuesdk = mc.getAttr( str(poserLoc) + '.translateY' )
            
            ani_node = self.findNode_animation( driver = str(poserLoc) + '.translateY' , driven = str(mouthBridge)+'.'+str('mouth_open') )
            
            self.modify_ani_node_float( aini_node = ani_node ,float = ( 0,0 ) ,floatValue = valuesdk )
            self.modify_ani_node_float( aini_node = ani_node ,float = ( 1,1 ) ,floatValue = 0 )
            
            self.modify_ani_node_value(  aini_node = ani_node ,float = ( 0,0) ,Value = 1)
            self.modify_ani_node_value(  aini_node = ani_node ,float = ( 1,1) ,Value = 0)
            
            
            print(ani_node)
            
            
            ##==============================================
            if mdlar_section == 1 or mdlar_section == 3:
                
                attr_list = lf_list
                
            elif mdlar_section == 2:
                attr_list = rt_list
            ###---       
            #if sdk_driverEmotion[0] == 'open' : 
            if mdlar_section == 1 or mdlar_section == 3:
                
                attr_list = lf_list
                
            elif mdlar_section == 2:
                attr_list = rt_list
            
            
            
            for sdk_attr in attr_list:
                
                #if mdlar_section == 1 or mdlar_section == 2:
                connected_obj = mc.listConnections( str(mouthBridge_offset) +'.' + sdk_attr , s=False , d=True )
                driver_value = mc.getAttr( str(mouthBridge_offset) +'.' + sdk_attr  )
                
                num_w = 0
                for cb in connected_obj:
                    
                    sdk_drivenAttr  = mc.listConnections( str(cb) +'.output'  , s = False , d = True , p=True )

                    value = mc.getAttr( sdk_drivenAttr[0])
                    
                    #print([str(mouthBridge_offset) +'.' + sdk_attr , driver_value ,sdk_drivenAttr[0] , value ])
                    self.LZ_setDrivenKey( driverAttr = str(mouthBridge_offset) +'.' + sdk_attr  ,drivenAttr = sdk_drivenAttr[0] , driverV= driver_value ,drivenV = value )
                
                    if mdlar_section == 3:
                        
                        if 'lf_' in sdk_attr:
                            sdk_attr_rt = str(sdk_attr).replace('lf_','rt_')
                            connected_obj_rt = mc.listConnections( str(mouthBridge_offset) +'.' + sdk_attr_rt , s=False , d=True )
                            driver_value_rt = mc.getAttr( str(mouthBridge_offset) +'.' + sdk_attr_rt  )
                            
                            #for cb_rt in connected_obj_rt:
                            
                                #
                                
                            sdk_drivenAttr_rt  = mc.listConnections( str(connected_obj_rt[num_w]) +'.output'  , s = False , d = True , p=True )
                            
                            
                            self.LZ_setDrivenKey( driverAttr = str(mouthBridge_offset) +'.' + sdk_attr_rt  ,drivenAttr = sdk_drivenAttr_rt , driverV= driver_value_rt ,drivenV = value )
                
                    num_w = num_w+1
        ####--------------------------------------------------------------     


        
        lf_conner = []
        rt_conner = []
        
        lf_upper_attrs = []
        lf_lower_attrs = []
        
        rt_upper_attrs = []
        rt_lower_attrs = []
        
        cn_upper_attrs = []
        cn_lower_attrs = []
        
        if sdk_driverEmotion[0] == 'lf_zipper' : 
            #zipper_attr
            #All_attr
            
            for a_attr in All_attr:
                if 'lf_' in a_attr :
                    #lf_attr.append( a_attr )
                    if 'uplips' in a_attr :
                        
                        lf_upper_attrs.append(a_attr)
                        
                    elif 'lowlips' in a_attr :
                        lf_lower_attrs.append(a_attr)
                        
                    else:
                        lf_conner.append(a_attr)
                        
                elif 'rt_' in a_attr :
                    #rt_attr.append( a_attr )
                    
                    if 'uplips' in a_attr :
                        
                        rt_upper_attrs.append(a_attr)
                        
                    elif 'lowlips' in a_attr :
                        rt_lower_attrs.append(a_attr)
                        
                    else:
                        rt_conner.append(a_attr)
        
        
                else:
                    if 'uplips' in a_attr :
                        
                        cn_upper_attrs.append(a_attr)
                        
                    elif 'lowlips' in a_attr :
                        cn_lower_attrs.append(a_attr)
        
        
        #lf_up_attributes_info = []
        
        All_attrs_grp =  [ lf_upper_attrs , lf_lower_attrs , rt_upper_attrs , rt_lower_attrs  ]
        #print(All_attrs_grp)
        attr_grp = []
        
        print(All_attrs_grp)
        for  num in  range(len(All_attrs_grp))  :
            
            
            
            if num == 0 or num == 2 :
                part_num = [ 7,8]
            else:
                part_num = [ 8,9]
            attributes_info = []
            for  i in All_attrs_grp[num]:
                
                parts = str(i).split('_')[-2]
                #print( parts)
                if len(parts) == part_num[0]:
                    value = int(parts[part_num[0] - 1::])
                elif len(parts) == part_num[1]:
                    value = int(parts[part_num[0] - 2::])
                else:
                    value = 0
                attributes_info.append([ i , value ])
                
                #lf_upper_attrs.remove(i)
                
            #print(attributes_info)
            #sorted(a)
            squence_num = []            
            for ab  in   attributes_info :
                
                squence_num.append(ab[1] )
            
            
            all_num = sorted(squence_num)
            #print(all_num)
            squence_attr = []
            for a_num in all_num :
                for a_i in attributes_info:
                    if a_i[1] == a_num:
                        squence_attr.append(a_i[0])
                        
                
            attr_grp.append(squence_attr)
        
        #print(attr_grp)

        upplid_all =   lf_conner + attr_grp[0][::-1] + cn_upper_attrs + attr_grp[2] + rt_conner
        reverse_upplid_all = upplid_all[::-1]
        lowlid_all = lf_conner + attr_grp[1][::-1] + cn_lower_attrs + attr_grp[3] + rt_conner
        reverse_lowlid_all = lowlid_all[::-1]

        if sdk_driverEmotion[0] == 'lf_zipper' :  
            #mount = 0        
            #value_float_all = []
            #for ul_num in range(len(upplid_all)):
            #    #value = mc.getAttr( str(mouthBridge_offset)+'.'+str(upplid_all[ul_num])  )
            #    #print(value)
            #    #if value == 0 :
            #        #break
            #    value_float_all.append(value)
            #    mount = mount+1
            #    #self.modify_ani_node_float( aini_node = node_ani ,float = ( 0,0 ) ,floatValue = 0 )
            #    #self.modify_ani_node_float( aini_node = node_ani ,float = ( 1,2) ,floatValue = value )
            #    
            #if mount >1:
            mount = len(upplid_all)
            for i in range(mount):
                value_sdk_float = (1.0/mount) * (i+1)
                
                value = mc.getAttr( str(mouthBridge_offset)+'.'+str(upplid_all[i])  )
                
                driverAttribute = str(mouthBridge_offset)+'.L_zipper'
                drivenAttribute = str(mouthBridge_offset)+'.'+str(upplid_all[i])
                
                #print([ upplid_all[i] ,value_sdk_float ])
                #self.LZ_setDrivenKey( driverAttribute,drivenAttribute,driverV,drivenV)
                
                node_ani = self.findNode_animation( driver = driverAttribute, driven = drivenAttribute )
                self.modify_ani_node_float( aini_node = node_ani ,float = ( 0,0 ) ,floatValue = 0 )
                
                self.modify_ani_node_value(  aini_node = node_ani ,float = ( 0,0) ,Value = 0)
                self.modify_ani_node_float( aini_node = node_ani ,float = ( 1,1) ,floatValue = value_sdk_float )
                
                self.modify_ani_node_value( aini_node = node_ani ,float = ( 1,1) ,Value = value)
                
                ##================================  
                #reverse_value = mc.getAttr( str(mouthBridge_offset)+'.'+str(reverse_upplid_all[i])  )
                reverse_driverAttribute = str(mouthBridge_offset)+'.R_zipper'
                reverse_drivenAttribute = str(mouthBridge_offset)+'.'+str(reverse_upplid_all[i])
                reverse_node_ani = self.findNode_animation( driver = reverse_driverAttribute, driven = reverse_drivenAttribute )
            
                #print(reverse_node_ani)
                self.modify_ani_node_float( aini_node = reverse_node_ani ,float = ( 0,0 ) ,floatValue = 0 )
                
                self.modify_ani_node_value(  aini_node = reverse_node_ani ,float = ( 0,0) ,Value = 0)
                self.modify_ani_node_float( aini_node = reverse_node_ani ,float = ( 1,1) ,floatValue = value_sdk_float )
                
                self.modify_ani_node_value( aini_node = reverse_node_ani ,float = ( 1,1) ,Value = value)
                
            mount = len(lowlid_all)
            for i in range(mount):
                value_sdk_float = (1.0/mount) * (i+1)
                
                value = mc.getAttr( str(mouthBridge_offset)+'.'+str(lowlid_all[i])  )
                
                driverAttribute = str(mouthBridge_offset)+'.L_zipper'
                drivenAttribute = str(mouthBridge_offset)+'.'+str(lowlid_all[i])
                #print(value)
                #print([ upplid_all[i] ,value_sdk_float ])
                #self.LZ_setDrivenKey( driverAttribute,drivenAttribute,driverV,drivenV)
                
                node_ani = self.findNode_animation( driver = driverAttribute, driven = drivenAttribute )
                self.modify_ani_node_float( aini_node = node_ani ,float = ( 0,0 ) ,floatValue = 0 )
                
                self.modify_ani_node_value(  aini_node = node_ani ,float = ( 0,0) ,Value = 0)
                self.modify_ani_node_float( aini_node = node_ani ,float = ( 1,1) ,floatValue = value_sdk_float )
                
                self.modify_ani_node_value( aini_node = node_ani ,float = ( 1,1) ,Value = value)
                
                ##================================  
                #reverse_value = mc.getAttr( str(mouthBridge_offset)+'.'+str(reverse_upplid_all[i])  )
                reverse_driverAttribute = str(mouthBridge_offset)+'.R_zipper'
                reverse_drivenAttribute = str(mouthBridge_offset)+'.'+str(reverse_lowlid_all[i])
                reverse_node_ani = self.findNode_animation( driver = reverse_driverAttribute, driven = reverse_drivenAttribute )
            
                #print(reverse_node_ani)
                self.modify_ani_node_float( aini_node = reverse_node_ani ,float = ( 0,0 ) ,floatValue = 0 )
                
                self.modify_ani_node_value(  aini_node = reverse_node_ani ,float = ( 0,0) ,Value = 0)
                self.modify_ani_node_float( aini_node = reverse_node_ani ,float = ( 1,1) ,floatValue = value_sdk_float )
                
                self.modify_ani_node_value( aini_node = reverse_node_ani ,float = ( 1,1) ,Value = value)
            
    